using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Files Test Class
  /// </summary>
  [TestClass]
  public class TestFiles
  {
    #region Class Variables
    private CdoPrms<DOFiles>		m_Files;
    private CdoPrmsList<DOFiles>	m_AllFiles;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestFiles()
    {
      // Create the data objects
      this.m_Files	= new CdoPrms<DOFiles>();
      this.m_AllFiles	= new CdoPrmsList<DOFiles>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Files data objects
    /// </summary>
    [TestMethod]
    public void FilesRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllFiles.DataObject = new DOFiles();
      this.m_AllFiles.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllFiles.PerformAction())
      {
        // Assert the errors
        if (this.m_AllFiles.Errors.Count > 0) { Assert.Fail(this.m_AllFiles.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Files
    /// </summary>
    [TestMethod]
    public void FilesCreate()
    {
      // Set up the data object for creation
      this.m_Files.DataObject.BoxNo = "Test BoxNo";
      this.m_Files.DataObject.DivisionName = "Test DivisionName";
      this.m_Files.DataObject.DepartmentName = "Test DepartmentName";
      this.m_Files.DataObject.CategoryName = "Test CategoryName";
      this.m_Files.DataObject.ProductName = "Test ProductName";
      this.m_Files.DataObject.ArchiveId = 10;
      this.m_Files.DataObject.FileStatus = "Test FileStatus";
      this.m_Files.DataObject.Notes = "Test Notes";
      this.m_Files.DataObject.Description = "Test Description";
      this.m_Files.DataObject.FromNo = 10;
      this.m_Files.DataObject.ToNo = 10;
      this.m_Files.DataObject.FromDate = DateTime.Now;
      this.m_Files.DataObject.ToDate = DateTime.Now;
      this.m_Files.DataObject.FromAlpha = "Test FromAlpha";
      this.m_Files.DataObject.ToAlpha = "Test ToAlpha";
      this.m_Files.DataObject.CreatedDate = DateTime.Now;
      this.m_Files.DataObject.CreatedByUserId = 12.3F;
      this.m_Files.DataObject.RequestId = 10;
      this.m_Files.DataObject.RequestDate = DateTime.Now;
      this.m_Files.DataObject.RequestedByUserId = 12.3F;
      this.m_Files.DataObject.RequestedDate = DateTime.Now;
      this.m_Files.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Files.PerformAction())
      {
        // Assert the errors
        if (this.m_Files.Errors.Count > 0) { Assert.Fail(this.m_Files.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Files
    /// </summary>
    [TestMethod]
    public void FilesRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Files.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Files.DataObject.FileNo = "Test FileNo";
      }

      // Set up the data object action for retrieval
      this.m_Files.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Files.PerformAction())
      {
        // Assert the errors
        if (this.m_Files.Errors.Count > 0) { Assert.Fail(this.m_Files.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
